//#region File Description
////-----------------------------------------------------------------------------
//// PlatformerGame.cs
////
//// Microsoft XNA Community Game Platform
//// Copyright (C) Microsoft Corporation. All rights reserved.
////-----------------------------------------------------------------------------
//#endregion

//using System;
//using System.IO;
//using Microsoft.Xna.Framework;
//using Microsoft.Xna.Framework.Graphics;
//using Microsoft.Xna.Framework.Input;
//using Microsoft.Xna.Framework.Media;
//using Microsoft.Xna.Framework.Input.Touch;


//namespace Platformer
//{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
   ////////////////////////////// public class PlatformerGame : Microsoft.Xna.Framework.Game
    //{
       // // Resources for drawing.
       // private GraphicsDeviceManager graphics;
       // private SpriteBatch spriteBatch;

       // // Jeremiah 3/11/2012
       //// ScreenManager screenManager;

       // // Global content.
       // private SpriteFont hudFont;

       // private Texture2D winOverlay;
       // private Texture2D loseOverlay;
       // private Texture2D diedOverlay;

       // // Meta-level game state.
       // private int levelIndex = -1;
       // private Level level;
       // private bool wasContinuePressed;

       // // When the time remaining is less than the warning time, it blinks on the hud
       // private static readonly TimeSpan WarningTime = TimeSpan.FromSeconds(30);

       // // We store our input states so that we only poll once per frame, 
       // // then we use the same input state wherever needed
       // private GamePadState gamePadState;
       // private KeyboardState keyboardState;
       // private TouchCollection touchState;
       // private AccelerometerState accelerometerState;

       // // The number of levels in the Levels directory of our content. We assume that
       // // levels in our content are 0-based and that all numbers under this constant
       // // have a level file present. This allows us to not need to check for the file
       // // or handle exceptions, both of which can add unnecessary time to level loading.
       // private const int numberOfLevels = 21; //12 means only 11 (talking 0-11)levels ;)

//        public PlatformerGame()
//        {



//            graphics = new GraphicsDeviceManager(this);
//            //graphics.PreferredBackBufferWidth = BackBufferWidth;
//            // graphics.PreferredBackBufferHeight = BackBufferHeight;

//            Content.RootDirectory = "Content";

//            // Create the screen manager component.
//            //screenManager = new ScreenManager(this);

//           // Components.Add(screenManager);

//            // Activate the first screens.
//            //screenManager.AddScreen(new BackgroundScreen(), null);
//            //screenManager.AddScreen(new MainMenuScreen(), null);

//            // Framerate differs between platforms.
//            // TargetElapsedTime = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / TargetFrameRate);






//            //graphics = new GraphicsDeviceManager(this);
//            //Content.RootDirectory = "Content";

//#if WINDOWS_PHONE
//            graphics.IsFullScreen = true;
//            TargetElapsedTime = TimeSpan.FromTicks(333333);
//#endif

//            Accelerometer.Initialize();
//        }

        ///// <summary>
        ///// LoadContent will be called once per game and is the place to load
        ///// all of your content.
        ///// </summary>
        //protected override void LoadContent()
        //{
        //    // Create a new SpriteBatch, which can be used to draw textures.
        //    spriteBatch = new SpriteBatch(GraphicsDevice);

        //    // Load fonts
        //    hudFont = Content.Load<SpriteFont>("Fonts/Hud");

        //    // Load overlay textures
        //    winOverlay = Content.Load<Texture2D>("Overlays/you_win");
        //    loseOverlay = Content.Load<Texture2D>("Overlays/you_lose");
        //    diedOverlay = Content.Load<Texture2D>("Overlays/you_died");

        //    //Known issue that you get exceptions if you use Media PLayer while connected to your PC
        //    //See http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/c8a243d2-d360-46b1-96bd-62b1ef268c66
        //    //Which means its impossible to test this from VS.
        //    //So we have to catch the exception and throw it away
        //    //try
        //    //{
        //    //    MediaPlayer.IsRepeating = true;
        //    //    MediaPlayer.Play(Content.Load<Song>("Sounds/Music"));
        //    //}
        //    //catch { }

        //    //LoadLevelMusic();
        //    LoadNextLevel();
        //}

        ///// <summary>
        ///// Allows the game to run logic such as updating the world,
        ///// checking for collisions, gathering input, and playing audio.
        ///// </summary>
        ///// <param name="gameTime">Provides a snapshot of timing values.</param>
        //protected override void Update(GameTime gameTime)
        //{
        //    // Handle polling for our input and handling high-level input
        //    HandleInput();

        //    // update our level, passing down the GameTime along with all of our input states
        //    level.Update(gameTime, keyboardState, gamePadState, touchState,
        //                 accelerometerState, Window.CurrentOrientation);

        //    base.Update(gameTime);
        //}

        //////////////////private void HandleInput()
        //////////////////{
        //////////////////    // get all of our input states
        //////////////////    keyboardState = Keyboard.GetState();
        //////////////////    gamePadState = GamePad.GetState(PlayerIndex.One);
        //////////////////    touchState = TouchPanel.GetState();
        //////////////////    accelerometerState = Accelerometer.GetState();

        //////////////////    // Exit the game when back is pressed.
        //////////////////    if (gamePadState.Buttons.Back == ButtonState.Pressed)
        //////////////////        Exit();

        //////////////////    bool continuePressed =
        //////////////////        keyboardState.IsKeyDown(Keys.Space) ||
        //////////////////        gamePadState.IsButtonDown(Buttons.A) ||
        //////////////////        touchState.AnyTouch();

        //////////////////    // Perform the appropriate action to advance the game and
        //////////////////    // to get the player back to playing.
        //////////////////    if (!wasContinuePressed && continuePressed)
        //////////////////    {
        //////////////////        if (!level.Player.IsAlive)
        //////////////////        {
        //////////////////            level.StartNewLife();
        //////////////////        }
        //////////////////        else if (level.TimeRemaining == TimeSpan.Zero)
        //////////////////        {
        //////////////////            if (level.ReachedExit)
        //////////////////                LoadNextLevel();
        //////////////////            else
        //////////////////                ReloadCurrentLevel();
        //////////////////        }
        //////////////////    }

        //////////////////    wasContinuePressed = continuePressed;
        //////////////////}

        //private void LoadNextLevel()
        //{
        //    // move to the next level
        //    levelIndex = (levelIndex + 1) % numberOfLevels;

        //    // Loads the next levels music :D - works grrrrreat :D
        //    LoadLevelMusic();

        //    // Unloads the content for the current level before loading the next one.
        //    if (level != null)
        //        level.Dispose();

        //    // Load the level.
        //    string levelPath = string.Format("Content/Levels/{0}.txt", levelIndex);
        //    using (Stream fileStream = TitleContainer.OpenStream(levelPath))
        //        level = new Level(Services, fileStream, levelIndex);
        //}

        //private void LoadLevelMusic()
        //{
        //    switch (levelIndex)
        //    {
        //        case 0:
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true; //Groton wakes from coma
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Scenes/OutliersSCENE1Hospital"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 1:
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true;
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/ExpandYourPotential"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 2:
        //            {
        //                try
        //                {
        //                    //MediaPlayer.IsRepeating = true;
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/ExpandYourPotential"));
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Scenes/OutliersSCENE2Reunion"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 3:
        //            {
        //                try
        //                {
        //                    //MediaPlayer.IsRepeating = true;
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/ExpandYourPotential"));
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/JungleTheme"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 4: //level4.txt
        //            {
        //                try
        //                {
        //                    //MediaPlayer.IsRepeating = true; 
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/ExpandYourPotential"));
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Scenes/OutliersSCENE3HelloOldFriend"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 5: //level5.txt
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true; //login into the tor network
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Scenes/OutliersSCENE2Reunion"));
                           
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/JungleTheme"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 6: //level6.txt
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true;
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/JungleTheme"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 7: //level7.txt
        //            {
        //                try
        //                {
        //                    //MediaPlayer.IsRepeating = true;
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/JungleTheme"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 8: //level8.txt
        //            {
        //                try
        //                {
        //                    //MediaPlayer.IsRepeating = true;
        //                    //MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/JungleTheme"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 9: //level9.txt
        //            {
        //                try
        //                {
        //                   // MediaPlayer.IsRepeating = true; 
        //                   // MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/JungleTheme"));
        //                   //// MediaPlayer.Play(Content.Load<Song>("Sounds/Scenes/OutliersSCENE2Reunion"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 10: //level10.txt
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true; //Groton saves Zander
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Scenes/OutliersSCENE3HelloOldFriend"));
        //                   // MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/ForThoseAboutToRock"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 11: //level11.txt
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true;
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/ForThoseAboutToRock"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        case 12: //level12.txt
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true;
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/ForThoseAboutToRock"));
        //                }
        //                catch { }
        //                break;
        //            }
        //        default:
        //            {
        //                try
        //                {
        //                    MediaPlayer.IsRepeating = true;
        //                    MediaPlayer.Play(Content.Load<Song>("Sounds/Soundtrack/SoThisIsWhatHeavenIsLike"));
        //                }
        //                catch { }
        //                break;
        //            }
        //    }

        //}

        //private void ReloadCurrentLevel()
        //{
        //    --levelIndex;
        //    LoadNextLevel();
        //}

        ///// <summary>
        ///// Draws the game from background to foreground.
        ///// </summary>
        ///// <param name="gameTime">Provides a snapshot of timing values.</param>
        //protected override void Draw(GameTime gameTime)
        //{


        //    //////graphics.GraphicsDevice.Clear(Color.Black);

        //    //////// The real drawing happens inside the screen manager component.
        //    //////base.Draw(gameTime);

        //    graphics.GraphicsDevice.Clear(Color.CornflowerBlue);


        //  //  spriteBatch.Begin();

        //    level.Draw(gameTime, spriteBatch);

        //    DrawHud();

        //  //  spriteBatch.End();

        //    base.Draw(gameTime);
        //}

        ////Drawing the  "Heads Up Display" HUD
        //private void DrawHud()
        //{
        //    spriteBatch.Begin(); //2012

        //    Rectangle titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;
        //    Vector2 hudLocation = new Vector2(titleSafeArea.X, titleSafeArea.Y);
        //    Vector2 center = new Vector2(titleSafeArea.X + titleSafeArea.Width / 2.0f,
        //                                 titleSafeArea.Y + titleSafeArea.Height / 2.0f);

        //    // Draw time remaining. Uses modulo division to cause blinking when the
        //    // player is running out of time.
        //    string timeString = "TIME REMAINING: " + level.TimeRemaining.Minutes.ToString("00") + ":" + level.TimeRemaining.Seconds.ToString("00");
        //    Color timeColor;
        //    if (level.TimeRemaining > WarningTime ||
        //        level.ReachedExit ||
        //        (int)level.TimeRemaining.TotalSeconds % 2 == 0)
        //    {
        //        timeColor = Color.White;
        //    }
        //    else
        //    {
        //        timeColor = Color.Red;
        //    }
        //    DrawShadowedString(hudFont, timeString, hudLocation, timeColor);

        //    // Draw score
        //    float timeHeight = hudFont.MeasureString(timeString).Y;
        //    DrawShadowedString(hudFont, "SCORE: " + level.Score.ToString(), hudLocation + new Vector2(0.0f, timeHeight * 1.2f), Color.White);

        //    // Determine the status overlay message to show.
        //    Texture2D status = null;
        //    if (level.TimeRemaining == TimeSpan.Zero)
        //    {
        //        if (level.ReachedExit)
        //        {
        //            status = winOverlay;
        //        }
        //        else
        //        {
        //            status = loseOverlay;
        //        }
        //    }
        //    else if (!level.Player.IsAlive)
        //    {
        //        status = diedOverlay;
        //    }

        //    if (status != null)
        //    {
        //        // Draw status message.
        //        Vector2 statusSize = new Vector2(status.Width, status.Height);
        //        spriteBatch.Draw(status, center - statusSize / 2, Color.White);
        //    }

        //    spriteBatch.End(); //2012
        //}

        //private void DrawShadowedString(SpriteFont font, string value, Vector2 position, Color color)
        //{
        //    spriteBatch.DrawString(font, value, position + new Vector2(1.0f, 1.0f), Color.Black);
        //    spriteBatch.DrawString(font, value, position, color);
        //}
//    }
//}
